var Game = {
	createCanvas:function(){
		var myCanvas = document.createElement("canvas");
        var sizeArr = this.calcSize();
        myCanvas.setAttribute("width", sizeArr[0]);
        myCanvas.setAttribute("height", sizeArr[1]);
        myCanvas.setAttribute("id", "board");
        myCanvas.style.border = "2px solid grey";
        document.getElementById("main").appendChild(myCanvas);
        return myCanvas;
    },
    calcSize:function(){
    	var sizeArr = [];
    	if(window.innerWidth > 1000){
    		sizeArr = [800,800];
    	} else if (window.innerWidth >= 768) {
    		sizeArr = [600,600];
    	} else if(window.innerWidth >= 480){
    		sizeArr = [400,400];
    	} else {
    		sizeArr = [300,300];
    	}
    	return sizeArr;
    },
    start: function(canvasObj) {
    	Chess.canvas = canvasObj;
    	Chess.initBoard();
    	Chess.initData();
        AI.moveChess();
        Chess.canvas.onclick = function(e) {
        	e = e ? e : window.event;
        	var chessX = Math.round(e.offsetX / Chess.gridSize);
        	var chessY = Math.round(e.offsetY / Chess.gridSize);
        	Chess.markChess(chessX, chessY);
            AI.moveChess();
        };
    },
    showResult: function(chessColor) {
    	switch (chessColor) {
    		case -1:
    		alert("white chess win!");
    		location.reload();
    		break;
    		case 1:
    		alert("black chess win!");
    		location.reload();
    		break;
    		default:
    		alert("Game over!");
    		location.reload();
    		break;
    	}
    	return;
    }
};